package com.lbb.springbootstock.v2.bean;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * K线数据
 */
public class KlineData {

    private String TradingDay;//交易日期
    private String High;//最高价
    private String Open;//开盘价
    private String Low;//最低价
    private String Close;//关盘价
    private String Amount;//交易金额

    public String getTradingDay() {
        return TradingDay;
    }

    public void setTradingDay(String tradingDay) {
        TradingDay = TimeStamp2Date(tradingDay);
    }

    public String getHigh() {
        return High;
    }

    public void setHigh(String high) {
        High = String.format("%.2f", Double.parseDouble(high));
    }

    public String getOpen() {
        return Open;
    }

    public void setOpen(String open) {
        Open = String.format("%.2f", Double.parseDouble(open));
    }

    public String getLow() {
        return Low;
    }

    public void setLow(String low) {
        Low = String.format("%.2f", Double.parseDouble(low));
    }

    public String getClose() {
        return Close;
    }

    public void setClose(String close) {
        Close = String.format("%.2f", Double.parseDouble(close));
    }

    public String getAmount() {
        return Amount;
    }

    public void setAmount(String amount) {
        Amount = amount;
    }

    public String TimeStamp2Date(String timestampString) {
        String formats = "yyyyMMdd";
        Long timestamp = Long.parseLong(timestampString) * 1000;
        //日期格式字符串
        String dateStr = new SimpleDateFormat(formats, Locale.CHINA).format(new Date(timestamp));
        return dateStr;
    }
}
